var e = require("../core");
Component((0, e.formItem)()({
  externalClasses: ["selector-content-class", "custom-value-class"],
  properties: {
    placeholder: {
      type: String,
      value: "请选择"
    },
    mode: {
      type: String,
      value: "selector"
    },
    multiSelectorType: {
      type: String,
      value: "driver"
    },
    multiSelectorMax: {
      type: Number,
      value: 1
    },
    rangeList: {
      type: Array,
      value: []
    },
    showClear: {
      type: Boolean,
      value: !0
    },
    showMore: {
      type: Boolean,
      value: !0
    },
    machineName: {
      type: String,
      value: ""
    },
    brandName: {
      type: String,
      value: ""
    }
  },
  data: {
    value: null,
    labelName: "",
    visible: !1
  },
  observers: {
    value: function (e) {
      if (Array.isArray(e)) {
        var a = null == e ? void 0 : e.map((function (e) {
          return null == e ? void 0 : e.name
        }));
        null != a && a.length && this.setData({
          labelName: a.join(",")
        })
      } else this.setData({
        labelName: (null == e ? void 0 : e.name) || ""
      })
    }
  },
  pageLifetimes: {
    show: function () {
      var e = $.router.getParams();
      if ("machinery" == (null == e ? void 0 : e["select-type"]) && "machine" == this.data.mode) {
        if (null != e && e.label && null != e && e.value) {
          var a, i = null === (a = e.value) || void 0 === a ? void 0 : a[0];
          this.onChange({
            id: i.id,
            name: i.name,
          })
        }
      } else if (
        "engineeringOwner" == this.data.mode && e["select-type"] && e["select-type"] == 'engineeringOwner'
      ) {
        this.onChange({
          id: e.value[0].id,
          name: e.value[0].name,
          phone: e.value[0].contactUserPhone
        })
      } else if (
        "excavatorOwner" == this.data.mode && e["select-type"] && e["select-type"] == 'excavatorOwner'
      ) {
        this.onChange({
          id: e.value[0].id,
          name: e.value[0].name
        })
      } else if (
        "project" == this.data.mode && e["select-type"] && e["select-type"] == 'project'
      ) {
        this.onChange({
          id: e.value[0].id,
          name: e.value[0].name,
          phone: e.value[0].contactUserPhone
        })
      } else if (
        "driverOwner" == this.data.mode && e["select-type"] && e["select-type"] == 'driverOwner'
      ) {
        this.onChange({
          id: e.value[0].id,
          name: e.value[0].name,
          phone: e.value[0].contactUserPhone
        })
      } else "machineBrand" == (null == e ? void 0 : e["select-type"]) && "brand" == this.data.mode ? e.id && e.name && this.onChange({
        id: e.id,
        name: e.name
      }) : "machineModal" == (null == e ? void 0 : e["select-type"]) && "model" == this.data.mode && e.id && e.name && this.onChange({
        id: e.id,
        name: e.name
      })
    }
  },
  methods: {
    onSwitchPopup: function () {
      this.setData({
        visible: !this.data.visible
      })
    },
    onChangeeMultiPicker: function (e) {
      this.onChange(e.detail.value || [])
    },
    onPickerItemClick: function (e) {
      var a = e.target.dataset.item;
      this.setData({
        visible: !1
      }), this.onChange({
        id: a.id,
        name: a.name
      })
    },
    onClose: function () {
      this.onChange("")
    },
    onTap: function () {
      var e = this.data,
        a = e.mode,
        i = e.machineName,
        t = e.brandName,
        l = this.getValues(),
        n = i ? l[i] : "",
        o = t ? l[t] : "";
      console.log(a)
      switch (a) {
        case "selector":
        case "multiSelector":
          this.onSwitchPopup();
          break;
        case "engineeringOwner":
          $.router.push("/subpackage/concat/list/index", {
            type: "engineeringOwner",
            isUpdateStorage: 0,
            selectValue: JSON.stringify(this.data.value ? [this.data.value] : [])
          });
          break;
        case "excavatorOwner":
          $.router.push("/subpackage/concat/list/index", {
            type: "excavatorOwner",
            isUpdateStorage: 0,
            selectValue: JSON.stringify(this.data.value ? [this.data.value] : [])
          });
          break;
        case "driverOwner":
          $.router.push("/subpackage/concat/list/index", {
            type: "driverOwner",
            isUpdateStorage: 0,
            selectValue: JSON.stringify(this.data.value ? [this.data.value] : [])
          });
          break;
        case "project":
          $.router.push("/subpackage/rent/rent-list/index", {
            type: "project",
            isUpdateStorage: 0,
            selectValue: JSON.stringify(this.data.value ? [this.data.value] : [])
          });
          break;
        case "machine":
          $.router.push("/subpackage/common/multi-role-select/index", {
            type: "machinery",
            isUpdateStorage: 0,
            selectValue: JSON.stringify(this.data.value ? [this.data.value] : [])
          });
          break;
        case "brand":
          var s;
          n && $.router.push("/subpackage/common/machine-brand/index", {
            class_id: n.id,
            id: (null === (s = this.data.value) || void 0 === s ? void 0 : s.id) || null
          });
          break;
        case "model":
          var r;
          n && $.router.push("/subpackage/common/machine-modal/index", {
            class_id: n.id,
            brand_id: (null == o ? void 0 : o.id) || "",
            id: (null === (r = this.data.value) || void 0 === r ? void 0 : r.id) || null
          })
      }
    }
  }
}));